<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="tags.WagleTagManager"%>
<%@page import="java.util.ArrayList"%>


<%@page import="comm.util.SoptHashMap"%>
<%@page import="java.util.Date"%>
<%@page import="statics.SoptVars"%>
<%@page import="comm.util.DbTest"%>    
<%
	SoptHashMap hm = RequestManager.getRequest(request);
	
	WagleTagManager tagMan = new WagleTagManager();
	ArrayList lt = null;
	String today = "";
	String inputDay = "";
	DbTest dt = new DbTest();
	dt.testDbConnection();
	today = SoptVars.TODAY;
	boolean futureDate = false;
	if(hm.get("DATE")!=null){
		inputDay = hm.get("DATE").toString();
		Date curDate = new Date(Integer.parseInt(today.substring(0,4)),
				Integer.parseInt(today.substring(5,7)),
				Integer.parseInt(today.substring(8,10)));
		
		Date date = new Date(Integer.parseInt(inputDay.substring(0,4)),
				Integer.parseInt(inputDay.substring(5,7)),
				Integer.parseInt(inputDay.substring(8,10)));
		if(curDate.compareTo(date)<0){
			futureDate = true;
		}
		
		lt = tagMan.getTagsByDay(inputDay);
	}else{
		inputDay = today;
		lt = tagMan.getTodayTags();
	}
%>    

<%@page import="comm.util.RequestManager"%>
<%if(futureDate){ %>
	<script type="text/javascript">
		alarm("무슨일이 일어 날까요?^ㅡ^");
	</script>
<%} %>
<div>
	<%if(lt!=null && lt.size()>0){ %>

	<h2><%=inputDay%> Tags~ <%=lt.size() %>가지 이야기</h2>
	<div>
		<%for(int i=0;i<lt.size();i++){
			SoptHashMap tagM = (SoptHashMap)lt.get(i);%>
		<div class="mainTagItem">
			<a href="javascript:callRegContentForm('<%=tagM.get("TAG_SEQ")%>','<%=tagM.get("TAG_TEXT")%>');"
				 style="font-size:<%=(Integer.parseInt(tagM.get("COUNT").toString())+1)*0.1+1%>em;
				 <%=(Integer.parseInt(tagM.get("COUNT").toString())+1)>10?"font-weight:bold;":"" %>">
				<%=tagM.get("TAG_TEXT")%><span><%=tagM.get("COUNT").toString().equals("0")?"":tagM.get("COUNT")%></span>
			</a>
		</div>
		<%} %>
		<div class="clear"></div>
		<p>해당일 자정 다음,네이버 이슈검색어 랭킹 기준 산출</p>
	</div>
	<%}else{ %>
		<h2><%=inputDay%></h2>
		<%if(lt.size()==0){ %>
		<div class="mainTagItem">와글이에 저장된 태그가 없습니다.</div>
		<%}else{ %>
		<div class="mainTagItem">오늘의 태그들이 업데이트 되지 않았습니다.</div>
		<%} %>
	<%} %>
</div>